home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 11
/
Amoszine 11 (Disk 2 of 2).adf
/
Ben_Wyatt_Source.lha
/
Directory_Deleter.AMOS
/
Directory_Deleter.amosSourceCode
Wrap
AMOS Source Code
|
2004-04-12
|
1KB
|
46 lines
' Directory Deleter
' ~~~~~~~~~~~~~~~~~
' by Ben Wyatt, bwyatt@paston.co.uk
'
' Deletes directories - simple as that
F$=Fsel$("","LeaveMe","Go into directory to delete","and select 'Okay'")
F$=F$-"LeaveMe"
If F$<>"" : _DELETEDIR[F$] : End If
Edit
Procedure _DELETEDIR[F$]
' Delete directory (F$=Directory to delete)
' Add "/" if nessassary
If Right$(F$,1)<>"/" : F$=F$+"/" : End If
' Reserve an array to hold the filenames
MXFILES=511
Dim FILE$(MXFILES)
' Goes through the directory and stores everything in the array
FILENUM=0 : D$=Dir First$(F$)
While D$<>""
' Removes trailing spaces
X=29 : While Mid$(D$,X,1)=" " : Dec X : Wend
FILE$(FILENUM)=Left$(D$,X) : Inc FILENUM
D$=Dir Next$
Wend
If FILENUM>0
' Go through the directory array and delete everything
' If directory found, then it's deleted with this procedure recursively
For N=0 To FILENUM-1
D$=Right$(FILE$(N),Len(FILE$(N))-1)
If Left$(FILE$(N),1)="*" : _DELETEDIR[F$+D$]
Else Kill F$+D$
End If
Next N
End If
' Finally delete the actual directory
Kill Left$(F$,Len(F$)-1)
End Proc